package com.example.demo.controller;

import com.example.demo.entity.ExamExam;
import com.example.demo.entity.ExamGroup;
import com.example.demo.entity.ExamList;
import com.example.demo.service.impl.ExamExamServiceImpl;
import com.example.demo.service.impl.ExamGroupServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/group")
@RequiredArgsConstructor
@Component
public class ExamGroupController {

    private final ExamGroupServiceImpl examGroupService;
    @GetMapping("/selectgroup")
    public List<ExamGroup> selectgroup() {
        List<ExamGroup> list =examGroupService.list();
        return list;
    }

    @PostMapping("/addgroup")
    public boolean addgroup(@RequestBody ExamGroup examGroup) {
        boolean bol=examGroupService.save(examGroup);
        return bol;
    }

    @PostMapping("/updategroup")
    public boolean updategroup(@RequestBody ExamGroup examGroup) {
        boolean bol=examGroupService.updateById(examGroup);
        return bol;
    }

    @GetMapping("/deletegroup")
    public int deletegroup(Integer id) {
        int re =examGroupService.deletegroup(id);
        return re;
    }

}
